﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Gammar.Digger.SystemFramework;
using System.Collections.Generic;
public partial class CacheManager : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindData();
        }
    }

    private void BindData()
    {
        List<string> keys = CacheHelper.GetAllKeys();

        DataTable dt = new DataTable();

        dt.Columns.Add("id");
        dt.Columns.Add("key");

        for (int i = 0; i < keys.Count; i++)
        {
            DataRow row = dt.NewRow();
            row["id"] = i + 1;
            row["key"] = keys[i];
            dt.Rows.Add(row);
        }

        GridView1.DataSource = dt;
        GridView1.DataBind();
    }

    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        string keyName=GridView1.Rows[e.RowIndex].Cells[2].Text;
        CacheHelper.Remove(keyName);
        BindData();
    }
}
